{	Problem: http://codeforces.ru/problemset/problem/61/D
	Verdict: Accepted

}
var i,n,x,y,k,mi,j:longint; sum,cur,max:int64; w:array[1..100001] of boolean; a,b:array[1..100001] of array of integer;
procedure dfs(v:longint);
var i,count:longint;
begin
w[v]:=true;
count:=0;
for i:=0 to length(a[v])-1 do begin
  if w[a[v][i]]=false then begin
    if v=1 then begin
      cur:=0;
    end;
    inc(cur,b[v][i]);
    inc(count);
    dfs(a[v][i]);
    dec(cur,b[v][i]);
  end;
end;
if (count=0) and (max<cur) then begin
  max:=cur;
  mi:=v;
end;
end;
begin
fillchar(w,sizeof(w),false);
readln(n);
for i:=1 to n-1 do begin
  readln(x,y,k);
  setlength(a[x],length(a[x])+1);
  setlength(a[y],length(a[y])+1);
  setlength(b[x],length(b[x])+1);
  setlength(b[y],length(b[y])+1);
  a[x][length(a[x])-1]:=y;
  a[y][length(a[y])-1]:=x;
  b[x][length(b[x])-1]:=k;
  b[y][length(b[y])-1]:=k;
end;
max:=-1;
mi:=0;
dfs(1);
sum:=0;
for i:=1 to n do begin
  for j:=0 to length(b[i])-1 do inc(sum,b[i][j]);
end;
dec(sum,max);
writeln(sum);
end.